import java.util.ArrayList;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User:${USER}
 * Date:${YEAR}-${MONTH}-${DAY}
 * ${TIME}
 */
public class Main {
    public static void main(String[] args) {
        System.out.println("Hello world!");
    }
}
class Solution {
    public List<Integer> findAnagrams(String s, String p) {
        List<Integer> list=new ArrayList<>();
        char[] ss=s.toCharArray();
        char[] pp=p.toCharArray();
        int count=p.length();
        int n=0;
        int[] hashP=new int[26];
        int[] hashS=new int[26];
        for(char ch:pp)hashP[ch-'a']++;
        for(int left=0,right=0;right<s.length();right++){
            hashS[ss[right]-'a']++;
            char in=ss[right];
            if(hashS[in-'a']<=hashP[in-'a'])n++;
            if(right-left+1>count){
                char out=ss[left];
                if(hashS[out-'a']--<=hashP[out-'a']){
                    n--;
                }
                left++;
            }

            if(count==n)list.add(left);
        }
        return list;
    }
}